using System.Data.Entity;
using PhoneBook.Core.Domain.Contacts;
using PhoneBook.Core.Domain.Phones;
using PhoneBook.Core.Domain.UserGroups;
using PhoneBook.Data.Mapping;

namespace PhoneBook.Data
{
    public class PbContext : DbContext
    {
        static PbContext()
        {
            Database.SetInitializer<PbContext>(null);
        }

		public PbContext()
			: base("name=PbContext")
		{
		}

		public PbContext(string connStr):base(connStr)
		{
		}


        public DbSet<Contact> Contacts { get; set; }
        public DbSet<Phone> Phones { get; set; }
        public DbSet<UserGroup> UserGroups { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new ContactMap());
            modelBuilder.Configurations.Add(new PhoneMap());
            modelBuilder.Configurations.Add(new UserGroupMap());
        }
    }
}
